<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <%
        String basePath = request.getScheme() + "://" +
                request.getServerName() + ":" + request.getServerPort()
                + request.getContextPath() + "/";
    %>
    <%--这样设置后，用到路径时就会默认转换  如 json-->  localhost:8080/web/json  --%>
    <base href="<%=basePath%>"/>
    <meta charset="UTF-8">
    <title>Title</title>
    <%--这样才能正确引入--%>
    <script type="text/JavaScript" src="js/axios.min.js"></script>
    <script>
        window.onload = function () {
            document.getElementById("btn").onclick = function () {
                axios.get('json')
                    .then(function (response) {
                        console.log(response.data);
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            }
        }
    </script>
</head>
<body>
<h1>axios</h1>
<button id="btn">获取数据</button>
</body>
</html>